package com.sh.diytwo;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: sh
 * @Version 1.0
 * @Description:
 */
public class MainTestTwo {
    public static void main(String[] args) {

        MyThreadPoolTwo myThreadPoolTwo = new MyThreadPoolTwo(new MyBlockQueueTwo<>(5), 2, 5,1000, TimeUnit.SECONDS, new MyRejectPolicyTwo<Runnable>() {
            @Override
            public void reject(MyBlockQueueTwo<Runnable> myBlockQueueTwo, Runnable runnable) {
                myBlockQueueTwo.put(runnable);
            }
        });

        for (int i = 0; i < 10; i++) {
            final int taskId = i;
            myThreadPoolTwo.execute(() -> {
                System.out.println("任务 " + taskId + " 执行中...");
            });
        }
    }
}

